﻿<%@ Page Title="" Language="C#" MasterPageFile="~/OrderSite.master" AutoEventWireup="true"
CodeBehind="RawMaterialOrderPayments.aspx.cs" Inherits="XYZ_Inventory.RawMaterialOrderPayments" %>

<asp:Content ID="Content1" ContentPlaceHolderID="htmlHead" runat="server">
    <link href="Styles/DetailsView.css" rel="stylesheet" type="text/css"/>
    <link href="Styles/GridView.css" rel="stylesheet" type="text/css"/>
    <link href="Styles/ValidationSummary.css" rel="stylesheet" type="text/css"/>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="body" runat="server">
    <asp:DetailsView ID="DetailsView1" CssClass="detailsView" runat="server" Height="50px"
                     Width="125px" AutoGenerateRows="False" CellPadding="4" DataKeyNames="ID" DataSourceID="OrderPaymentSource"
                     DefaultMode="Insert" ForeColor="#333333" GridLines="None" Style="width: 20em"
                     HeaderText="Order Payment" OnItemInserted="DetailsView1_ItemInserted" OnItemInserting="DetailsView1_ItemInserting">
        <AlternatingRowStyle BackColor="White" ForeColor="#284775"/>
        <CommandRowStyle BackColor="#E2DED6" Font-Bold="True"/>
        <EditRowStyle BackColor="#999999"/>
        <FieldHeaderStyle BackColor="#E9ECF1" Font-Bold="True"/>
        <Fields>
            <asp:BoundField DataField="ID" HeaderText="ID" ReadOnly="True" SortExpression="ID"
                            InsertVisible="False"/>
            <asp:TemplateField HeaderText="Order ID" SortExpression="OrderID">
                <InsertItemTemplate>
                    <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("OrderID") %>' Width="75"
                                 TextMode="Number">
                    </asp:TextBox>
                    <asp:RequiredFieldValidator runat="server" ControlToValidate="TextBox1" ErrorMessage="Order Id is required."
                                                Text="*" ForeColor="Red" Display="Dynamic" ValidationGroup="Insert">
                    </asp:RequiredFieldValidator>
                    <asp:CustomValidator ID="CustomValidator1" runat="server" ErrorMessage="Invalid Order ID"
                                         OnServerValidate="CustomValidator1_OnServerValidate" ControlToValidate="TextBox1"
                                         Text="*" ForeColor="Red" Display="Dynamic" ValidationGroup="Insert">
                    </asp:CustomValidator>
                    <asp:HiddenField ID="hfPaymentDate" runat="server" Value='<%# Bind("PaymentDate") %>'/>
                </InsertItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Installment No" SortExpression="InstallmentNo">
                <InsertItemTemplate>
                    <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("InstallmentNo") %>' Width="75"
                                 TextMode="Number">
                    </asp:TextBox>
                </InsertItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Payment Credit Period" SortExpression="PaymentCreditPeriod">
                <InsertItemTemplate>
                    <asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("PaymentCreditPeriod") %>'
                                 Width="75" TextMode="Number">
                    </asp:TextBox>
                </InsertItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Amount" SortExpression="Amount">
                <InsertItemTemplate>
                    <asp:TextBox ID="TextBox4" runat="server" Text='<%# Bind("Amount") %>' Width="100"
                                 TextMode="Number" min="1">
                    </asp:TextBox>
                    <asp:RequiredFieldValidator runat="server" ControlToValidate="TextBox4" ErrorMessage="Amount is required."
                                                Text="*" ForeColor="Red" Display="Dynamic" ValidationGroup="Insert">
                    </asp:RequiredFieldValidator>
                </InsertItemTemplate>
            </asp:TemplateField>
            <asp:CommandField ShowInsertButton="True" ShowCancelButton="False" ValidationGroup="Insert"/>
            <asp:TemplateField ShowHeader="False">
                <ItemStyle BackColor="#E2DED6"/>
                <InsertItemTemplate>
                    <asp:ValidationSummary ID="ValidationSummary1" CssClass="validationSummary" HeaderText="<b>Please fix following error(s):</b>"
                                           ValidationGroup="Insert" ForeColor="Red" runat="server"/>
                </InsertItemTemplate>
            </asp:TemplateField>
        </Fields>
        <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White"/>
        <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White"/>
        <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center"/>
        <RowStyle BackColor="#F7F6F3" ForeColor="#333333"/>
    </asp:DetailsView>
    <asp:EntityDataSource ID="OrderPaymentSource" runat="server" ConnectionString="name=XYZDBContext"
                          DefaultContainerName="XYZDBContext" EnableDelete="True" EnableFlattening="False"
                          EnableInsert="True" EnableUpdate="True" EntitySetName="RawMaterialOrderPayments"
                          EntityTypeFilter="RawMaterialOrderPayment">
    </asp:EntityDataSource>
    <br/>
    <br/>
    <h2>
        Payment History
    </h2>
    <br/>
    <div class="gridViewContainer">
        <asp:GridView ID="GridView1" CssClass="gridView" runat="server" AllowPaging="True"
                      AllowSorting="True" AutoGenerateColumns="False" CellPadding="4" DataSourceID="OrderPaymentSource"
                      ForeColor="#333333" GridLines="None">
            <AlternatingRowStyle BackColor="White" ForeColor="#284775"/>
            <Columns>
                <asp:BoundField DataField="ID" HeaderText="ID" SortExpression="ID" ReadOnly="True">
                    <ItemStyle HorizontalAlign="Right"/>
                </asp:BoundField>
                <asp:BoundField DataField="OrderID" HeaderText="Order ID" SortExpression="OrderID"
                                ReadOnly="True">
                    <ItemStyle HorizontalAlign="Right"/>
                </asp:BoundField>
                <asp:BoundField DataField="PaymentDate" HeaderText="Payment Date" SortExpression="PaymentDate"
                                ReadOnly="True" DataFormatString="{0:d}"/>
                <asp:TemplateField HeaderText="Installment No" SortExpression="InstallmentNo">
                    <ItemTemplate>
                        <asp:Label ID="Label1" runat="server" Text='<%# Bind("InstallmentNo") %>'></asp:Label>
                    </ItemTemplate>
                    <EditItemTemplate>
                        <asp:TextBox ID="TextBox1" runat="server" TextMode="Number" Width="75" Text='<%# Bind("InstallmentNo") %>'></asp:TextBox>
                    </EditItemTemplate>
                    <ItemStyle HorizontalAlign="Right"/>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Payment Credit Period" SortExpression="PaymentCreditPeriod">
                    <ItemTemplate>
                        <asp:Label ID="Label2" runat="server" Text='<%# Bind("PaymentCreditPeriod") %>'></asp:Label>
                    </ItemTemplate>
                    <EditItemTemplate>
                        <asp:TextBox ID="TextBox2" runat="server" TextMode="Number" Width="75" Text='<%# Bind("PaymentCreditPeriod") %>'></asp:TextBox>
                    </EditItemTemplate>
                    <ItemStyle HorizontalAlign="Right"/>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Amount" SortExpression="Amount">
                    <ItemTemplate>
                        <asp:Label ID="Label3" runat="server" Text='<%# Bind("Amount") %>'></asp:Label>
                    </ItemTemplate>
                    <EditItemTemplate>
                        <asp:TextBox ID="TextBox3" runat="server" TextMode="Number" min="1" Width="100" Text='<%# Bind("Amount") %>'></asp:TextBox>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="TextBox3"
                                                    ErrorMessage="Amount is required." Text="*" ForeColor="Red" Display="Dynamic"
                                                    ValidationGroup="Edit">
                        </asp:RequiredFieldValidator>
                    </EditItemTemplate>
                    <ItemStyle HorizontalAlign="Right"/>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Action" ShowHeader="False">
                    <ItemTemplate>
                        <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" CommandName="Edit"
                                        Text="Edit">
                        </asp:LinkButton>
                        &nbsp;<asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" CommandName="Delete"
                                              OnClientClick="return confirm('Are you sure you want to delete this product?');"
                                              Text="Delete">
                        </asp:LinkButton>
                    </ItemTemplate>
                    <EditItemTemplate>
                        <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="True" ValidationGroup="Edit"
                                        CommandName="Update" Text="Update">
                        </asp:LinkButton>
                        &nbsp;<asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" CommandName="Cancel"
                                              Text="Cancel">
                        </asp:LinkButton>
                    </EditItemTemplate>
                </asp:TemplateField>
            </Columns>
            <EditRowStyle BackColor="#999999"/>
            <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White"/>
            <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White"/>
            <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center"/>
            <RowStyle BackColor="#F7F6F3" ForeColor="#333333"/>
            <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333"/>
            <SortedAscendingCellStyle BackColor="#E9E7E2"/>
            <SortedAscendingHeaderStyle BackColor="#506C8C"/>
            <SortedDescendingCellStyle BackColor="#FFFDF8"/>
            <SortedDescendingHeaderStyle BackColor="#6F8DAE"/>
        </asp:GridView>
        <asp:ValidationSummary ID="ValidationSummary2" Style="margin-top: 1em;" CssClass="validationSummary"
                               HeaderText="<b>Please fix following error(s):</b>" ValidationGroup="Edit" ForeColor="Red"
                               runat="server"/>
    </div>
</asp:Content>